home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / Direct3D / AutoParts / data.cls < prev    next >
Text File  |  2001-10-08  |  4KB  |  177 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "Data"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10.  
  11. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  12. '
  13. '  Copyright (C) 1999-2001 Microsoft Corporation.  All Rights Reserved.
  14. '
  15. '  File:       data.cls
  16. '  Content:    DATA MIDDLEWARE           
  17. '              replace with your favorite
  18. '              database code
  19. '
  20. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  21.  
  22.  
  23. Private Type rec
  24.     AssemblyId As Long
  25.     ModelPart As String
  26.     PartID As String
  27.     Description As String
  28.     Price As Currency
  29.     CompatibleParts As String
  30.     Stock As String
  31.     PartMake As String
  32. End Type
  33.  
  34. Dim rs() As rec
  35. Dim index As Integer
  36. Dim lastindex As Integer
  37. Dim maxsize As Integer
  38.  
  39. Public Function MoveTop()
  40.     index = 0
  41.     MoveTop = True
  42. End Function
  43.  
  44. Public Function IsEOF()
  45.     If index = -1 Then IsEOF = True
  46. End Function
  47. Public Function MoveNext()
  48.     If index = lastindex Then
  49.         index = -1
  50.         Exit Function
  51.     End If
  52.         
  53.     index = index + 1
  54.     MoveNext = True
  55. End Function
  56.  
  57. Public Property Get ModelPart() As String
  58.     ModelPart = rs(index).ModelPart
  59. End Property
  60.  
  61. Public Property Get PartID() As String
  62.     PartID = rs(index).PartID
  63. End Property
  64.  
  65. Public Property Get Description() As String
  66.     Description = rs(index).Description
  67. End Property
  68.  
  69. Public Property Get Price() As Currency
  70.     Price = rs(index).Price
  71. End Property
  72.  
  73. Public Property Get CompatibleParts() As String
  74.     CompatibleParts = rs(index).CompatibleParts
  75. End Property
  76.  
  77. Public Property Get Stock() As String
  78.     Stock = rs(index).Stock
  79. End Property
  80.  
  81. Public Property Get PartMake() As String
  82.     PartMake = rs(index).PartMake
  83. End Property
  84.  
  85. Public Function MoveToModelPartRecord(sname As String) As Boolean
  86.     
  87.     For index = 0 To lastindex
  88.         If (UCase(rs(index).ModelPart) = UCase(sname)) Then
  89.             MoveToModelPartRecord = True
  90.             Exit Function
  91.         End If
  92.     Next
  93.     MoveToModelPartRecord = False
  94. End Function
  95.  
  96. Function InitData(sFile As String) As Boolean
  97.     Dim strData As String
  98.     On Local Error GoTo errOut
  99.     
  100.     ReDim rs(100)
  101.     maxsize = 100
  102.     
  103.     Dim fl As Long
  104.     fl = FreeFile
  105.     index = 0
  106.     Open sFile For Input As #fl
  107.     Line Input #fl, strData
  108.     Do While Not EOF(fl)
  109.         Line Input #fl, strData
  110.     
  111.         
  112.         Dim j As Long, q As Long
  113.         Dim r As rec
  114.         
  115.         'Assembly ID - what assembly does this belong to
  116.         j = 1
  117.         q = InStr(j, strData, Chr(9))
  118.         r.AssemblyId = Mid$(strData, 1, q - 1)
  119.         
  120.         'Unique ID for all parts
  121.         j = q + 1
  122.         q = InStr(j, strData, Chr(9))
  123.         r.PartID = Mid$(strData, j, q - j)
  124.     
  125.         'Model Part .. whats the name of the part in the xfile
  126.         j = q + 1
  127.         q = InStr(j, strData, Chr(9))
  128.         r.ModelPart = Mid$(strData, j + 1, q - 2 - j)
  129.         
  130.         'Part Price
  131.         j = q + 1
  132.         q = InStr(j, strData, Chr(9))
  133.         r.Price =val(Mid$(strData, j + 1, q - 1 - j))
  134.         
  135.         'Description
  136.         j = q + 1
  137.         q = InStr(j, strData, Chr(9))
  138.         r.Description = Mid$(strData, j + 1, q - 2 - j)
  139.         
  140.         'Stock
  141.         j = q + 1
  142.         q = InStr(j, strData, Chr(9))
  143.         r.Stock = Mid$(strData, j, q - j)
  144.         
  145.         'PartMake
  146.         j = q + 1
  147.         q = InStr(j, strData, Chr(9))
  148.         r.PartMake = Mid$(strData, j + 1, q - j - 2)
  149.                 
  150.         'CompatibleParts
  151.         j = q + 1
  152.         r.CompatibleParts = Mid$(strData, j + 1)
  153.         q = Len(r.CompatibleParts) - 1
  154.         r.CompatibleParts = Mid$(r.CompatibleParts, 1, q)
  155.         
  156.         If index > maxsize Then
  157.             maxsize = maxsize + 100
  158.             ReDim Preserve rs(maxsize)
  159.         End If
  160.         
  161.         rs(index) = r
  162.         lastindex = index
  163.         index = index + 1
  164.         
  165.     Loop
  166.     InitData = True
  167.     Exit Function
  168. errOut:
  169.     InitData = False
  170. End Function
  171.    
  172.    
  173.  
  174.  
  175.  
  176.  
  177.